<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
    Object danx=request.getSession().getAttribute("danxlist");
    System.out.println("单选:"+danx);
%>
<head >
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>模拟测试-开始</title>
    <link rel="stylesheet" type="text/css" href="/examproject/css/dt.css" />
    <style type="text/css">
        .demo{width:760px; margin:60px auto 10px auto}
    </style>

</head>
<body>

<div class="demo">
    <div id='quiz-container'></div>
    <p>注:如果未成功生成试卷,原因是题库题目不够....</p>
    <a href="/examproject/nologin/index.jsp">返回首页</a>
</div>
<script type="text/javascript" src="/examproject/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="/examproject/js/quiz.js"></script>
<script type="text/javascript">
    var wt=[];
    var init={'questions':wt}
    var xmlhttp=new XMLHttpRequest();
    window.onload=function(){
        xmlhttp.open("GET","/examproject/stu/getmnsj",true);
        xmlhttp.send();
        xmlhttp.onreadystatechange=function(){
            if(xmlhttp.readyState==4 && xmlhttp.status==200){
                var sz=JSON.parse(xmlhttp.responseText);
                var a=0;
                for(var i=0;i<sz.length;i++){
                    if(sz[i].question_answer=="A") {
                       a=0;
                    }else if(sz[i].question_answer=="B") {
                       a=1;
                    }else if(sz[i].question_answer=="C") {
                       a=2;
                    }else if(sz[i].question_answer=="D") {
                       a=3;
                    }
                    wt[i] = {
                        'question': sz[i].question_name,
                        'answers': [sz[i].question_optiona, sz[i].question_optionb, sz[i].question_optionc, sz[i].question_optiond],
                        'correctAnswer': a
                    };
                    }
                $(function(){
                    $('#quiz-container').jquizzy({
                        questions: init.questions
                    });
                });
            }

        }
    }


</script>
</body>
</html>
